package FinalProject

class SearchController {

    def searchService

    def index = {
        def searchResults = null
        def query = params.query
        if (params.type == "searchUser")  {
            searchResults = searchService.searchUser(query)
            render(template:"userindex", model:[result: searchResults, viewType: "SiteUser"])
        }
        else if (params.type == "searchGame") {
            searchResults = searchService.searchGame(query)
            render(template:"gameindex", model:[result: searchResults, viewType: "Game"])
        }
        else if (params.type == "searchPlatform") {
            searchResults = searchService.searchPlatform(query)
            render(template:"platformindex", model:[result: searchResults, viewType: "Platform"])
        }

    }
}
